#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define ms0(a) memset(a,0,sizeof a)
#define msp(a) memset(a,0x3f,sizeof a)
#define msn(a) memset(a,-1,sizeof a)
#define mc(a,b) memcpy(a,b,sizeof b)
#define endl '\n'
#define pii pair<int,int>

constexpr int mod=1e9+7;
constexpr int N=1e5+7,M=1e6+7;
bool bg_m;
int Case=1;
inline void cmax(int &a,int b){a=a<b?b:a;}
inline void cmin(int &a,int b){a=a>b?b:a;}
inline int qp(int a,int b){int res=1;
while(b){if(b&1)res=1ll*res*a%mod;a=1ll*a*a%mod;b>>=1;}return res;}

int n,m,l,v;
int d,pv,a;
int tl,tr;
int ll[N],rr[N];
int pos[N],sum[M];
int dp[N];
int ans1;
struct node{
    int l,r;
}p[N];
int cnt;
inline int ceil(int a,int b){
    if(a==0) return 0;
    return (a-1)/b+1;
}

void Main(){

    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++){
        ll[i]=rr[i]=0;
        cin>>d>>pv>>a;
        if(a==0){
            if(pv<=v) continue;
            tl=d,tr=l;
        }else if(a>0){
            if(pv>v){
                tl=d,tr=l;
            }else{
                if((v*v-pv*pv)>=(l-d)*(2*a)) continue;
                tl=d+1+(v*v-pv*pv)/(2*a);
                tr=l;
            }
        }else{
            if(pv<=v) continue;
            tl=d;
            if((pv*pv-v*v)>(l-d)*(-2*a)) tr=l;
            else tr=d-1+ceil(pv*pv-v*v,-2*a);
        }
        ll[i]=tl,rr[i]=tr;
    }
    ms0(sum);
    ans1=cnt=0;
    for(int i=1;i<=m;i++) cin>>pos[i],sum[pos[i]]=1;
    for(int i=1;i<=1000000;i++) sum[i]+=sum[i-1];
    for(int i=1;i<=n;i++){
        if(ll[i]>rr[i]) continue;
        if(sum[rr[i]]-(ll[i]?sum[ll[i]-1]:0)==0) continue;
        p[++cnt]={ll[i],rr[i]};
        ans1++;
    }
    cout<<ans1<<" ";
    sort(p+1,p+cnt+1,[](node a,node b){return a.r!=b.r?a.r<b.r:a.l>b.l;});
    int j=1,curl=0,mxl=0;
    for(int i=1;i<=cnt;i++) cmax(mxl,p[i].l);
    if(mxl==0) return cout<<m<<endl,void();
    for(int i=1;i<=m;i++){
        while(j<=cnt&&p[j].r<pos[i]) cmax(curl,p[j].l),j++;
        dp[i]=dp[lower_bound(pos,pos+i,curl)-pos]+1;
        if(pos[i]>=mxl){
            cout<<m-dp[i]<<endl;
            return;
        }
    }
    return;
}
string RdFile="detect";
bool en_m;
signed main(){
    freopen((RdFile+".in").c_str(),"r",stdin);
    freopen((RdFile+".out").c_str(),"w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>Case;
    while(Case--) Main();
    // cerr<<(&en_m-&bg_m)/1024.0/1024<<endl;
    return 0;
}
/*
g++ detect.cpp -o detect -g -Wall -Wextra -Wshadow -fsanitize=address,undefined -std=c++14
g++ detect.cpp -o detect ‐O2 ‐std=c++14 ‐static
*/